#ifndef __IMMEDIATERENDERER_H__
#define __IMMEDIATERENDERER_H__

#include "RendererBase.h"
#include "Mesh.h"
#include <GL/GL.h>

class ImmediateRenderer : public RendererBase
{
public:
	void RenderMesh(const Mesh &mesh)
	{
		BindTexture(mesh.Texture);

		glPushMatrix();

		glTranslatef(mesh.Pivot.X, mesh.Pivot.Y, mesh.Pivot.Z);
		glRotatef(mesh.Rotate.X, 1, 0, 0);
		glRotatef(mesh.Rotate.Y, 0, 1, 0);
		glRotatef(mesh.Rotate.Z, 0, 0, 1);
		glTranslatef(-mesh.Pivot.X, -mesh.Pivot.Y, -mesh.Pivot.Z);

		glTranslatef(mesh.Translate.X, mesh.Translate.Y, mesh.Translate.Z);

		glBegin(mesh.Mode);

		for (std::vector<Face>::const_iterator face = mesh.Faces.begin(); face != mesh.Faces.end(); ++face)
		{
			for (std::vector<int>::const_iterator index = (*face).Indices.begin(); index != (*face).Indices.end(); ++index)
			{
				glColor4ubv(&(*face).Colors[*index].R);
				glTexCoord2fv(&(*face).TexCoords[*index].X);
				glVertex3fv(&(*face).Vertices[*index].X);
			}
		}
		glEnd();

		glPopMatrix();
	}
};

#endif 